﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>字典明细管理</title>
    <#include "../common/link.ftl" >
    <script>
        $(function () {
            // 给选中的字典目录添加高亮的回显效果
            $("a[data-id=${qo.parentId}]").addClass("active");

            /*模态框*/
            $(".btn-input").click(function () {
                // 清空表单中所有input中的value值
                $("#editForm input").val('');
                // 回显目录标题
                $("#editForm input[name=parentTitle]").val($('#dic .active').html());
                $("#editForm input[name=parentId]").val(${qo.parentId});

                // 获取事件源,通过data获取data开头属性的数据
                var json = $(this).data('json');
                console.log(json);
                if (json) {
                    $('#editForm input[name=id]').val(json.id);
                    $('#editForm input[name=title]').val(json.title);
                    $('#editForm input[name=sequence]').val(json.sequence);
                }
                /*打开模块框*/
                $("#inputModal").modal('show');
            })
        });
    </script>
</head>
<body class="hold-transition skin-blue sidebar-mini">
<div class="wrapper">
    <#include "../common/navbar.ftl">
    <!--菜单回显-->
    <#assign currentMenu="systemDictionaryItem"/>
    <#include "../common/menu.ftl">
    <div class="content-wrapper">
        <section class="content-header">
            <h1>字典明细管理</h1>
        </section>
        <section class="content">
            <div class="box">
                <div class="row" style="margin:20px">
                    <div class="col-xs-3">
                        <div class="panel panel-default">
                            <div class="panel-heading">字典目录</div>
                            <div class="panel-body">
                                <div class="list-group" id="dic">
                                    <#--目录名称-->
                                    <#list systemDictionaries as sd>
                                        <a href="/systemDictionaryItem/list.do?parentId=${sd.id}"
                                           class="list-group-item" data-id="${sd.id}">${(sd.title)!}</a>
                                    </#list>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="col-xs-9">
                        <table>
                            <form class="form-inline" id="searchForm" action="/systemDictionaryItem/list.do"
                                  method="post">
                                <input type="hidden" name="currentPage" id="currentPage" value="1">
                                <#--解决,点击下一页时数据丢失问题(比如说选中的是客户重要程度,点击下一页时又跳转去查询默认目录的数据)-->
                                <input type="hidden" name="parentId" value="${qo.parentId!}">
                                <a href="#" class="btn btn-success btn-input"
                                   style="margin: 10px">
                                    <span class="glyphicon glyphicon-plus"></span> 添加
                                </a>
                            </form>
                            <!--编写内容-->
                            <div class="box-body table-responsive no-padding ">
                                <table class="table table-hover table-bordered">
                                    <tr>
                                        <th>编号</th>
                                        <th>标题</th>
                                        <th>序号</th>
                                        <th>操作</th>
                                    </tr>
                                    <#list pageInfo.list as systemDictionaryItem>
                                        <tr style="font-weight: bolder;color:green">
                                            <td>${systemDictionaryItem_index+1}</td>
                                            <td>${(systemDictionaryItem.title)!}</td>
                                            <td>${(systemDictionaryItem.sequence)!}</td>
                                            <td>
                                                <a href="#" data-json='${(systemDictionaryItem.json)!}'
                                                   class="btn btn-info btn-xs btn-input">
                                                    <span class="glyphicon glyphicon-pencil"></span> 编辑
                                                </a>
                                                <a href="#" data-id="${(systemDictionaryItem.id)!}"
                                                   class="btn btn-danger btn-xs btn-delete">
                                                    <span class="glyphicon glyphicon-trash"></span> 删除
                                                </a>
                                            </td>
                                        </tr>
                                    </#list>
                                </table>
                                <!--分页-->
                                <#include "../common/page.ftl" >
                            </div>
                        </table>
                    </div>
                </div>

            </div>
        </section>
    </div>
    <#include "../common/footer.ftl">
</div>

<#--模态框,动态弹出所以要给按钮添加点击事件-->
<div class="modal fade" id="inputModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog" role="document">
        <div class="modal-content">

            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span>
                </button>
                <h4 class="modal-title" id="myModalLabel" style="font-weight: bolder" align="center">字典明细添加/修改</h4>
            </div>


            <#--添加表单-->
            <form class="form-horizontal" action="/systemDictionaryItem/saveOrUpdate.do" method="post" id="editForm">
                <div class="modal-body">
                    <input type="hidden" value="${(systemDictionaryItem.id)!}" name="id">

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-4 control-label">字典目录：</label>
                        <div class="col-sm-4">
                            <#--目录标题,给用户看的-->
                            <input type="text" class="form-control col-sm-6" id="parentTitle" name="parentTitle"
                                   readonly>
                            <#--目录id,后台关联目录用-->
                            <input type="hidden" class="form-control col-sm-6" id="parentId" name="parentId" readonly>
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="name" class="col-sm-4 control-label">明细标题:</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control col-sm-6" id="title" name="title" placeholder="请输入明细标题">
                        </div>
                    </div>

                    <div class="form-group" style="margin-top: 10px;">
                        <label for="sn" class="col-sm-4 control-label">明细序号：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control col-sm-6" id="sequence" name="sequence"
                                   placeholder="请输入字典目录序号">
                        </div>
                    </div>

                </div>


                <div class="modal-footer">
                    <button type="button" class="btn btn-default" data-dismiss="modal" style="background-color:
                red"><font color="black" style="font-weight: bolder">关闭</font>
                    </button>
                    <button id="submitBtn" type="submit" class="btn btn-primary"><font color="black"
                                                                                       style="font-weight: bolder">保存</font>
                    </button>
                </div>


            </form>
        </div>
    </div>
</div>
</body>
</html>